# encoding: utf-8
# @File  : page_ht_login.py
# @Author: wu shaofan
# @Date  :  2024/04/29
# @Desc :
from selenium.webdriver.common.by import By
from PO.base.base import Base


class PageHtLogin(Base):
    # 用户名输入框
    login_username = By.NAME, "username"
    # 密码输入框
    login_password = By.NAME, "password"
    # 验证码输入框
    login_verify_code = By.ID, "vertify"
    # 点击登录按钮
    login_btn = By.NAME, "submit"
    # 错误信息提示
    login_error_msg = By.ID, "error"

    # 输入用户名
    def page_input_username(self, username):
        self.base_input(self.login_username, username)
        self.base_get_allure_image()

    # 输入密码
    def page_input_password(self, pwd):
        self.base_input(self.login_password, pwd)
        self.base_get_allure_image()

    # 输入验证码
    def page_input_verify_code(self, code):
        self.base_input(self.login_verify_code, code)
        self.base_get_allure_image()

    # 点击登录按钮
    def page_click_login_btn(self):
        self.base_click(self.login_btn)
        self.base_get_allure_image()

    # 获取错误提示信息
    def page_get_error_msg(self):
        return self.base_get_text(self.login_error_msg)

    # 封装后台登录账号
    def page_ht_login(self):
        self.page_input_username("admin")
        self.page_input_password("HM_2023_test")
        self.page_input_verify_code("8888")
        self.page_click_login_btn()
